package Starter;

import gate.IGateEx;

import java.rmi.AccessException;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.util.Date;

import main.GateComm;
import main.Server;
import master.MasterInterface;
import sr.logger.Logger;
import util.RmiService;

public class EntryClass 
{
	private static Logger logger =Logger.getLogger(EntryClass.class);
	public static void main(String[] args)
	{
		logger.log("main","Registering Master on Gate");
		
		
		try
		{
			IGateEx gate = (IGateEx)LocateRegistry.getRegistry().lookup("Gate");
			GateComm.setUpGateComm(gate);
			gate.registerServer(new Server());
			
		} catch (AccessException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (RemoteException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NotBoundException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.err.println("Master started and registered time: " + new Date());
		//RmiService.createNewRmiServer(Server.class,MasterInterface.class, "Server");
		
	}
}
